﻿using System;
using Autodesk.Revit.DB;

namespace YArchitech.HVAC
{
	public class ValveAndFitting
	{
		public ValveAndFitting()
		{
			this.resCoefLocal = 0.0;
		}

		public ValveAndFitting(Element element, ValveAndFittingType tp)
		{
			this.resCoefLocal = 0.0;
			this.elem = element;
			this.type = tp;
		}

		public ValveAndFitting(ValveAndFitting vf)
		{
			this.type = vf.ValveType;
			this.elem = vf.Element;
			this.resistanceLocal = vf.ResistanceLocal;
			this.resCoefLocal = vf.resCoefLocal;
		}

		public Element Element
		{
			get
			{
				return this.elem;
			}
			set
			{
				this.elem = value;
			}
		}

		public ValveAndFittingType ValveType
		{
			get
			{
				return this.type;
			}
			set
			{
				this.type = value;
			}
		}

		public string TypeName
		{
			get
			{
				ValveAndFittingTypeName valveAndFittingTypeName = (ValveAndFittingTypeName)this.type;
				return valveAndFittingTypeName.ToString();
			}
		}

		public ElementId Id
		{
			get
			{
				return this.elem.Id;
			}
		}

		public string Name
		{
			get
			{
				return this.GetElementFamily();
			}
		}

		public double ResistanceLocal
		{
			get
			{
				return this.resistanceLocal;
			}
			set
			{
				this.resistanceLocal = value;
			}
		}

		public double ResCoefLocal
		{
			get
			{
				return this.resCoefLocal;
			}
			set
			{
				this.resCoefLocal = value;
			}
		}

		public int ConnDiameter
		{
			set
			{
				this.diameter = value;
			}
		}

		private string GetElementFamily()
		{
			return (this.elem as FamilyInstance).Symbol.FamilyName;
		}

		private double CalcResistance()
		{
			return this.resistanceLocal;
		}

		public double GetResCoefLocal(int dn)
		{
			this.resCoefLocal = HeatingCalcTools.GetResCoefLocal(this.type, dn);
			return this.resCoefLocal;
		}

		private Element elem;

		private double resistanceLocal;

		private ValveAndFittingType type = ValveAndFittingType.Other;

		private double resCoefLocal;

		private int diameter;
	}
}
